package com.tr.ssocms.controller;

import com.tr.common.util.Result;
import com.tr.common.util.ResultStatus;
import com.tr.ssocms.service.AuthenticationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description: ssocontroller
 * @return {@link null}
 * @author  wangxihao
 * @email wangxh0108@163.com
**/
//@CrossOrigin
@RestController
@RequestMapping("/member")
public class MemberLoginController {

    @Resource
    private AuthenticationService remoteMemberService;

    /**
     * 登录
     * @param userName
     * @param password
     * @return
     */
    @GetMapping("/login")
    public Result getMember(String userName, String password){
        return new Result(ResultStatus.SUCCESS.getReturncode(), ResultStatus.SUCCESS.getReturnMessage(),remoteMemberService.checkUsernameAndPassword(userName,password));
    }

    /**
     * 验证Token
     * @param token
     * @return
     */
    @GetMapping("/reLogin")
    public Boolean checkUser(@RequestParam("token")String token){
        return remoteMemberService.checkToken(token);
    }
}
